import React, { useEffect, useState } from 'react';
import { getDeptList } from '@/api';

export default function useGetDeptList() {
  const [deptList, setDeptList] = useState([]);
  useEffect(() => {
    getDeptList().then((data) => {
      if (data?.length) {
        const list = data.map((i) => { return { name: i?.deptName, value: i?.deptId } })
        setDeptList(list)
      }
    })
      .catch((err) => {
        throw (err)
      });
  }, [])

  return deptList;
}